/*
 * CPUMonitor.java
 *
 * Created on May 5, 2009, 6:02 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package im.resources;

import java.io.Serializable;

/**
 *
 * @author bluejack
 */
public class CPUMonitor implements Serializable {
    float oldValue;
    
    /** Creates a new instance of CPUMonitor */
    public CPUMonitor() {
        oldValue = (float)(Math.random());              
    }
    
    public float check() {
		float cpu;
		if ( ((int)(Math.random()*1000) % 100) < 4)
			cpu = (float)(Math.random());
		
		else
			cpu = 0.9f * oldValue + 0.1f * (float)(Math.random());
							
		if (cpu<0.3f) {
		
			if (oldValue - cpu > 0.5)
				cpu = oldValue;
		}
		
		oldValue = cpu;
		
		//System.out.println("status="+cpu);
                
		return cpu;
	}
    
}
